{% extends 'generic/object_detail.html' %}
{% load helpers %}

{% block content_left_page %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Cluster</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Name</td>
                    <td>{{ object.name }}</td>
                </tr>
                <tr>
                    <td>Type</td>
                    <td><a href="{{ object.type.get_absolute_url }}">{{ object.type }}</a></td>
                </tr>
                <tr>
                    <td>Group</td>
                    <td>
                        {% if object.group %}
                            <a href="{{ object.group.get_absolute_url }}">{{ object.group }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Tenant</td>
                    <td>
                        {% if object.tenant %}
                            <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Site</td>
                    <td>
                        {% if object.site %}
                            <a href="{{ object.site.get_absolute_url }}">{{ object.site }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Virtual Machines</td>
                    <td><a href="{% url 'virtualization:virtualmachine_list' %}?cluster_id={{ object.pk }}">{{ object.virtual_machines.count }}</a></td>
                </tr>
            </table>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Comments</strong>
            </div>
            <div class="panel-body rendered-markdown">
                {% if object.comments %}
                    {{ object.comments|render_markdown }}
                {% else %}
                    <span class="text-muted">None</span>
                {% endif %}
            </div>
        </div>
{% endblock content_left_page %}

{% block content_right_page %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Host Devices</strong>
            </div>
            {% if perms.virtualization.change_cluster %}
                <form action="{% url 'virtualization:cluster_remove_devices' pk=object.pk %}" method="post">
                {% csrf_token %}
            {% endif %}
            {% include 'responsive_table.html' with table=device_table %}
            {% if perms.virtualization.change_cluster %}
                <div class="panel-footer noprint">
                    <div class="pull-right">
                        <a href="{% url 'virtualization:cluster_add_devices' pk=object.pk %}?site={{ object.site.pk }}" class="btn btn-primary btn-xs">
                            <span class="mdi mdi-plus-thick" aria-hidden="true"></span>
                            Add devices
                        </a>
                    </div>
                    <button type="submit" name="_remove" class="btn btn-danger primary btn-xs">
                        <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span>
                        Remove devices
                    </button>
                </div>
                </form>
            {% endif %}
        </div>
{% endblock content_right_page %}
